package com.spring.sunflower.common;

import com.spring.sunflower.base.BaseObserver;
import com.spring.sunflower.base.BasePresenter;
import com.spring.sunflower.bean.BlackListBean;
import com.spring.sunflower.bean.CommonBean;

import io.reactivex.rxjava3.core.Observable;

/**
 * Created by Kevin on 2021/7/15<br/>
 * <p>
 * Describe:<br/>
 */
public class BlackListPresenter extends BasePresenter<CommonContract.BlackListview> {
    public BlackListPresenter(CommonContract.BlackListview baseView) {
        super(baseView);
    }

    public void getBlackList(String userId, String pageIndex) {
        Observable<BlackListBean> observable = requestDataSource.requestBlackList(userId, pageIndex);
        addDisposable(observable, new BaseObserver<BlackListBean>(baseView) {

            @Override
            public void onSuccess(BlackListBean bean) {
                baseView.showBlackList(bean.getDatas());
            }

            @Override
            public void onError(int status, String msg) {

            }
        });
    }

    public void blackRemove(String blackRememberId) {
        Observable<CommonBean> observable = requestDataSource.requestRemoveBlack(blackRememberId);
        addDisposable(observable, new BaseObserver<CommonBean>(baseView) {

            public void onSuccess(CommonBean bean) {
                baseView.blackRemoveSuccess();
            }

            @Override
            public void onError(int status, String msg) {
                baseView.blackRemoveFailed();
            }
        });
    }
}
